<template>
  <div class="container">
    <h2>基础散点图</h2>
    <div class="chart-container">
      <div id="basicScatterChart" style="height:500px"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: "basicScatterChart",
  data() {
    return {
      option: {
        xAxis: {},
        yAxis: {},
        // 提示框组件
        tooltip: {
          trigger: "axis", // 坐标轴触发，主要在柱状图，折线图等会使用类目轴的图表中使用。
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        series: [
          {
            type: "effectScatter",
            symbolSize: 20,
            data: [
              [8.7, 10.2],
              [15.4, 4.2],
            ],
          },
          {
            symbolSize: 40,
            data: [
              [10.0, 8.04],
              [8.07, 6.95],
              [13.0, 7.58],
              [9.05, 8.81],
              [11.0, 8.33],
              [14.0, 7.66],
              [13.4, 6.81],
              [10.0, 6.33],
              [14.0, 8.96],
              [12.5, 6.82],
              [9.15, 7.2],
              [11.5, 7.2],
              [3.03, 4.23],
              [12.2, 7.83],
              [2.02, 4.47],
              [1.05, 3.33],
              [4.05, 4.96],
              [6.03, 7.24],
              [12.0, 6.26],
              [12.0, 8.84],
              [7.08, 5.82],
              [5.02, 5.68],
            ],
            type: "scatter",
          },
        ],
      },
    };
  },
  mounted() {
    this.getLineChart();
  },
  methods: {
    // 设置折线图
    getLineChart() {
      this.lineChart = this.$echart.init(
        document.getElementById("basicScatterChart")
      );
      this.lineChart.setOption(this.option);
    },
  },
};
</script>

<style lang="less">
.chart-container {
  canvas {
    // width: 200px !important;
  }
}
</style>